#ifndef DATAFLOW_DETAIL_ARGUMENTVECTORPRIVATE_H
#define DATAFLOW_DETAIL_ARGUMENTVECTORPRIVATE_H

#include <assert.h>
#include <vector>

#include <QSharedData>

#include "Argument.h"

namespace DataFlow
{

namespace Detail
{

class ArgumentVectorPrivate : public QSharedData
{
	public:

		typedef QSharedData           BaseType;
		typedef ArgumentVectorPrivate ThisType;

		ArgumentVectorPrivate(void)
		{
			;
		}

		ArgumentVectorPrivate(const ThisType & other)
			: BaseType(other)
			, uid(other.uid)
			, args(other.args)
		{
			;
		}

		ArgumentVectorPrivate(int id, int size)
			: uid(id)
			, args(size_t(size))
		{
			assert(size > 0);
		}

		~ArgumentVectorPrivate(void)
		{
			;
		}

		void setId(int id)
		{
			this->uid = id;
		}

		int id(void) const
		{
			return this->uid;
		}

		int size(void) const
		{
			return int(this->args.size());
		}

		void resize(int size)
		{
			assert(size >= 0);
			this->args.resize(size_t(size));
		}

		void reserve(int size)
		{
			assert(size >= 0);
			this->args.reserve(size_t(size));
		}

		void clear(void)
		{
			this->args.clear();
		}

		void pushBack(const Argument & arg)
		{
			this->args.push_back(arg);
		}

		void swap(ThisType & other)
		{
			this->args.swap(other.args);
		}

		/*
		void validate(void)
		{
			for (size_t i=0; i<this->args.size(); ++i)
			{
				this->args[i].validate();
			}
		}

		void invalidate(void)
		{
			for (size_t i=0; i<this->args.size(); ++i)
			{
				this->args[i].invalidate();
			}
		}

		bool isValid(void) const
		{
			for (size_t i=0; i<this->args.size(); ++i)
			{
				if (!this->args[i].isValid()) return false;
			}
			return true;
		}
		*/

		Argument & at(int index)
		{
			return this->args[index];
		}

		const Argument & at(int index) const
		{
			return this->args[index];
		}

		Argument & operator [] (int index)
		{
			return this->args[index];
		}

		const Argument & operator [] (int index) const
		{
			return this->args[index];
		}

	protected:

		typedef std::vector<Argument> ArgumentVectorType;

		int                uid;
		ArgumentVectorType args;
};

}

}

#endif // DATAFLOW_DETAIL_ARGUMENTVECTORPRIVATE_H
